﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using Caliburn.Micro;
using VirtualKeyboard.UI.Localize;

namespace VirtualKeyboard.UI
{
    [Export(typeof(IShell))]
    public sealed class MainViewModel : Screen, IShell
    {
        private readonly IWindowManager windowManager;
        private readonly ConfigViewModel configViewModel;
        private readonly Startup startup;

        private bool isShowingConfig;

        public string ConfigItemName { get; private set; }
        public string AboutItemName { get; private set; }
        public string ExitItemName { get; private set; }

        [ImportingConstructor]
        public MainViewModel(IWindowManager windowManager, ConfigViewModel configViewModel)
        {
            DisplayName = AppResources.AppName;
            ConfigItemName = AppResources.Config;
            AboutItemName = AppResources.About;
            ExitItemName = AppResources.Exit;

            this.windowManager = windowManager;
            this.configViewModel = configViewModel;
            startup = new Startup();
            startup.Srart();
        }

        public void OnConfig()
        {
            if (isShowingConfig) return;

            isShowingConfig = true;
            windowManager.ShowDialog(configViewModel);
            isShowingConfig = false;
        }

        public void OnAbout()
        {
            System.Diagnostics.Process.Start("http://virtualkeyboard.codeplex.com/");
        }

    }
}
